package show.me.the.money.service.core;




import java.util.HashMap;

import show.me.the.money.config.reportSchema.ReportSchemaController;
import show.me.the.money.config.reportSchema.define.ReportSchema;
import show.me.the.money.util.context.Context;
import show.me.the.money.util.context.HashMapContext;


public class ReportSchemaLoader implements Service{

	public void execute(HashMap<String,Object> req,HashMap<String,Object> res,Context ctx){
		int code = 200;
		String msg = "Success";
		
		String id = (String)req.get("schema");
		Context qCtx = new HashMapContext(req);
		ctx.putCtx("q", qCtx);
		ReportSchema reportSchema = ReportSchemaController.instance().getSchemaDynamic(id, ctx);
		if(reportSchema != null){
			res.put("body", reportSchema.json(ctx));
		}
		else{
			code = 404;
			msg = "NoSuchSchema";
		}
		res.put(RES_CODE, code);
		res.put(RES_MESSAGE, msg);
	}
	

}
